import { createStore } from 'vuex';
import LoginRegister from './modules/LoginRegister';

import link from '../api/link.js'
import apiUrl from '../api/apiUrl.js'

export default createStore({
  state: {
    showaside:true,//un use
    listdata:{},
    uplistdata:[]
  },
  mutations: {
    changShowAside(state:any){
      state.showaside = !state.showaside
    },
    ListData(state:any,paylog:any){
      state.listdata = paylog
    }
  },
  actions: {
    USERUPDATE_LIST(context:any){
      link(apiUrl.userlist).then((ok: any) => {
          console.log(ok);
          context.commit("LISTDATA",ok.data)
        });
  },
  DEL_DATA(context:any,payload:any){
      link(apiUrl.userlist+"/"+payload.id,"delete").then((ok:any)=>{
          console.log(ok)
          window.location.reload()
      })
  },
  },
  modules: {
    LoginRegister
  },
});
